package Java常用工具API.StringBuilder类和StringBuffer类;

public class Test {
    public static void main(String[] args) {

        //测试空参构造方法：StringBuilder():构造一个空的StringBuilder容器
        StringBuilder sb=new StringBuilder();
        String s1="爱上对方过后就哭了！";

        //测试StringBuilder append(...):将任意数据添加到StringBuilder容器中，返回自身容器
        sb.append(s1);
        sb.append(25);
        sb.append("java,我来了。");
        System.out.println(sb);
        System.out.println("--------------------------------");

        //测试有参构造方法：StringBuilder(String):构造一个StringBuilder容器，并添加指定字符串
        StringBuilder sb1=new StringBuilder("大海回复我。");
        StringBuilder sb5=new StringBuilder("200");
        System.out.println(sb1);
        System.out.println("--------------------------------");

        System.out.println(sb5);
        sb1.append(3666);
        System.out.println(sb1);
        System.out.println("--------------------------------");

        //测试String toString():将当前StringBuilder容器转换成字符串
        StringBuilder sb2=new StringBuilder("520");
        sb2.toString();
        String s2=sb2.toString();
        System.out.println(s2+1314);//不会进行加法运算，说明是字符串
        //System.out.println(sb2+1);这样不行



    }
}
